﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using XueMeng.BLL;
using XueMeng.Model;

namespace UI
{
    public partial class StudentMain : Form
    {
        public StudentMain()
        {
            InitializeComponent();
        }

        private void StudentMain_Load(object sender, EventArgs e)
        {
            this.dataGridView1.AutoGenerateColumns = false;
            LoadDate();
            LoadEvent();
        }

        private void LoadEvent()
        {
            this.dataGridView1.KeyUp += new KeyEventHandler(dataGridView1_KeyUp);
        }

        void dataGridView1_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode==Keys.F3)
            {
                if (this.dataGridView1.SelectedRows.Count>0)
                {
                    StudentManager sm = new StudentManager();
                    Help.TemporarySet.Student = sm.GetModel(Convert.ToInt32(this.dataGridView1.SelectedRows[0].Cells[0].Value));
                    this.Close();
                }
            }
        }


        private void LoadDate()
        {
            LoadStudent("");
        }

        private void LoadStudent(String Where)
        {
            StudentManager sm = new StudentManager();
            this.dataGridView1.DataSource = sm.GetList(Where).Tables[0];
        }
    }
}
